﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using System.IO;
using System.Web.Script.Serialization;

namespace TestBiblioteca
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void CreaTest()
        {
            string posdata = "{\"IdPublicacion\":\"2\",\"NuDias\":\"2\",\"NuDocumento \":\"09903031\"}";
            byte[] data = Encoding.UTF8.GetBytes(posdata);
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:3048/SolicitudService.svc/Solicitudes");
            req.Method = "POST";
            req.ContentLength = data.Length;
            req.ContentType = "application/json";
            var reqStream = req.GetRequestStream();
            reqStream.Write(data, 0, data.Length);
            HttpWebResponse res = null;
            res = (HttpWebResponse)req.GetResponse();
            StreamReader reader = new StreamReader(res.GetResponseStream());
            string alumnojson = reader.ReadToEnd();
            JavaScriptSerializer js = new JavaScriptSerializer();
            Solicitud solicitudcreada = js.Deserialize<Solicitud>(alumnojson);
            //Assert.AreEqual(9, alumnocreado.codigo);
            Assert.AreEqual("09903031", solicitudcreada.NuDocumento);
        }

    }
}
